﻿using MediatR;
using Microsoft.EntityFrameworkCore;
using Traceability.Commont.Domains.AnimalsDomainFiles;
using Traceability.Commont.DTOs;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace U.Enterprise.Api.Applications.Scalesetting
{
    public class LiveAnimalWeighingListDTOBackfillHandler : IRequestHandler<LiveAnimalWeighingListDTOBackfillCommand, Resqults<LiveAnimalWeighingListDTO>>
    {
        private readonly IBateRepository<LiveAnimalweighing> _liveanimalRepository;
        private readonly IBateRepository<Shopping> _shopingRepository;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="liveanimalRepository"></param>
        /// <param name="shopingRepository"></param>
        public LiveAnimalWeighingListDTOBackfillHandler(IBateRepository<LiveAnimalweighing> liveanimalRepository, IBateRepository<Shopping> shopingRepository)
        {
            _liveanimalRepository = liveanimalRepository;
            _shopingRepository = shopingRepository;
        }

        public Task<Resqults<LiveAnimalWeighingListDTO>> Handle(LiveAnimalWeighingListDTOBackfillCommand request, CancellationToken cancellationToken)
        {
            //try
            //{
            //    Resqults<LiveAnimalWeighingListDTO> res = new Resqults<LiveAnimalWeighingListDTO>();
            //    var list = from a in _liveanimalRepository.GetAll()
            //               join b in _shopingRepository.GetAll() on 
            //               select new LiveAnimalWeighingListDTO
            //               {
            //                   ApproachNo = a.ApproachNo,
            //                   ShoppingDesignationid = 
            //               };
            //    if (list != null)
            //    {
            //        resqults.Code = 1;
            //        resqults.Date = list;
            //        resqults.Messges = "反填显示成功";
            //    }
            //}
            //catch (Exception)
            //{

            //    resqults.Messges = "反填显示失败";
            //}
            //return resqults;
            throw new NotImplementedException();
        }
    }
}
